<?php
namespace app\admin\validate;

use think\Validate;

/**
* 
*/
class Banner extends Validate
{
   protected $rule = [
        'url'       => 'require|url',
        'describe'       => 'is:chsDash',
        'status'       => 'require',
		'bennerImg' => 'require'
    ];
    
    protected $message = [
        'url.require'          =>'请填写URL',
    	'url.url'		        =>'URL格式不正确',
		'describe.is'       => '只允许汉字、字母、数字和下划线_及破折号-',
		'bennerImg.require' => '请上传图片'
    ];
    protected $scene = [
        //编辑场景
        'edit'  => [
            'url' => 'require|url',
			'describe'=> 'is:chsDash',
			'status',
			'bennerImg' => 'require'
        ],
    ];

	/**
	*自定义验证 
	* 手机号格式检查
	* @param string $mobile
	* @return bool
	*/
	protected function check_mobile_number($mobile)
	{
	    if (!is_numeric($mobile)) {
	        return false;
	    }
	    $reg = '#^13[\d]{9}$|^14[5,7]{1}\d{8}$|^15[^4]{1}\d{8}$|^17[0,6,7,8]{1}\d{8}$|^18[\d]{9}$#';

	    return preg_match($reg, $mobile) ? true : false;
	}


}